<?php
namespace app\home\controller;

class Withdraw extends ControllerBase {
	public function _initialize() {
		$this -> checkLogin();
	}

	public function index() {
		$userId = \think\Session::get('user_id');
		// 富豪区钱包
		$resultUserWalletRich = (new \app\common\component\user_wallet_rich\UserWalletRichService) -> getUserWalletRichId($userId);
		$this -> view -> assign('user_wallet_rich', $resultUserWalletRich['data']['user_wallet_rich']);

		// 富豪区冻结
		$this -> view -> assign('sumUserWalletRichFreeze', \app\common\model\UserWalletRichFreeze::where('user_id', $userId) -> where('is_freeze', 0) -> sum('price + interest'));

		// 土豪区钱包
		$resultUserWalletUpstart = (new \app\common\component\user_wallet_upstart\UserWalletUpstartService) -> getUserWalletUpstartId($userId);
		$this -> view -> assign('user_wallet_upstart', $resultUserWalletUpstart['data']['user_wallet_upstart']);

		// 土豪区冻结
		$this -> view -> assign('sumUserWalletUpstartFreeze', \app\common\model\UserWalletUpstartFreeze::where('user_id', $userId) -> where('is_freeze', 0) -> sum('price + interest'));

		// 动态钱包
		$this -> view -> assign('sumUserWalletDynamicPrice', \app\common\model\UserWalletDynamic::where('user_id', $userId) -> where('status', 0) -> sum('remaining_price'));
        return $this -> view -> fetch();
	}
}
?>